//
// Created by 黄扬航 on 2023/4/18.
//

#include "Menu.h"
#include<windows.h>
#include<iostream>
#include"Tools.h"
#include"Map.h"
#include"Snake.h"
Tools Tool;
void Menu::PrintBeginMenu()
{
    auto a = new Tools;
    a->MoveCursorTo(25, 3, "Snake");
    a->MoveCursorTo(24, 5, "Easy Mode");
    a->MoveCursorTo(24, 6, "Normal Mode");
    a->MoveCursorTo(24, 7, "Hard Mode");
    delete a;
}

void Menu::PrintBorder()
{
    auto a = new Tools;
    for (int i = 0; i < MaxWidth; i++)
    {
        if (i == 0 || i == MaxWidth - 1)
        {
            for (int j = 0; j < MaxLength; j++)
            {
                COORD pos{(short) j, (short) i};
                DWORD written;
                WriteConsoleOutputCharacter(a->Console, "#", 1, pos, &written);
                Sleep(10);
            }
        }
        else
        {
            COORD pos{(short) 0, (short) i};
            DWORD written;
            WriteConsoleOutputCharacter(a->Console, "#", 1, pos, &written);
            pos = {(short) (MaxLength - 1), (short) i};
            WriteConsoleOutputCharacter(a->Console, "#", 1, pos, &written);
        }
    }
    delete a;
}

void Menu::PrintDiedMenu()
{
    Tool.MoveCursorTo(MaxLength/3, MaxWidth +2, "you are died!DO you want try again?");
    Tool.MoveCursorTo(MaxLength / 3, MaxWidth + 3, "Yes");
    Tool.MoveCursorTo(MaxLength / 3, MaxWidth + 4, "No");
}

void Menu::PrintPlayingMenu()
{
    Tool.MoveCursorTo(MaxLength + 5, MaxWidth *0.5-3, "Snake Score Board");
}

void Menu::Updata()
{
    Tool.MoveCursorTo(MaxLength + 7, MaxWidth*0.5-2, "Snake Size: ");
    Tool.MoveCursorTo(MaxLength + 19, MaxWidth * 0.5-2, Snake::SnakeSize);
    Tool.MoveCursorTo(MaxLength + 8, MaxWidth * 0.5-1, "CurrentScore: ");
    Tool.MoveCursorTo(MaxLength + 22, MaxWidth * 0.5-1, Snake::CurrentScore);
}
